package com.day02;

import com.day01.Hero;
import com.day02.MyIterable;

import java.util.*;

public class Tets {
    public static void main(String[] args) {
        //创建10个订单
/*
        ArrayList<JavaOrder> list = new ArrayList<>();
        list.add(new JavaOrder("001", "001", "001", "004", 25, 36));
        list.add(new JavaOrder("001", "002", "002", "007", 324, 44));
        list.add(new JavaOrder("002", "003", "003", "005", 84, 3));
        list.add(new JavaOrder("002", "004", "004", "004", 345, 53));
        list.add(new JavaOrder("002", "005", "005", "005", 869, 547));
        list.add(new JavaOrder("006", "006", "006", "005", 234, 43));
        list.add(new JavaOrder("007", "007", "007", "007", 4441, 168));
        list.add(new JavaOrder("008", "008", "008", "006", 656, 43));
        list.add(new JavaOrder("008", "009", "009", "006", 112, 75));
        list.add(new JavaOrder("010", "010", "010", "005", 312, 43));
*/

        //需求3：统计每一种品类下的订单总额  就按单个金额算
        //key 分类   value 金额   ==》for ==》   hashmap(品类，金额汇总)

/*        HashMap<String, Double> map = new HashMap<>();

        for (JavaOrder javaOrder : list) {
            Double value = map.getOrDefault(javaOrder.getCategory_id(), 0.0);
            map.put(javaOrder.getCategory_id(),javaOrder.getGoods_num()*javaOrder.getPrice()+value);
        }*/
/*
        Set<Map.Entry<String, Double>> entries = map.entrySet();
        for (Map.Entry<String, Double> entry : entries) {
            Double value = entry.getValue();
            String key = entry.getKey();
            System.out.println(key+"==>"+value);
        }*/


/*
        ArrayList<Map.Entry<String, Double>> list1 = new ArrayList<>(map.entrySet());

        Collections.sort(list1, new Comparator<Map.Entry<String, Double>>() {
            @Override
            public int compare(Map.Entry<String, Double> o1, Map.Entry<String, Double> o2) {
                return Double.compare(o1.getValue(),o2.getValue());
            }
        });

        for (Map.Entry<String, Double> entry : list1) {
            String key = entry.getKey();
            Double value = entry.getValue();
            System.out.println(key+"=>"+value);
        }

        //
        map.entrySet().stream().sorted(Map.Entry.comparingByValue((o1, o2) -> Double.compare(o2,o1))).forEach(System.out::println);
*/

        //源集合
        ArrayList<Integer> list = new ArrayList<>();
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);

        //目标集合
        ArrayList<Integer> res = new ArrayList<>();

        boolean flag = false;

        for (Integer i : list) {
            //如果不等于0   false 这个数据我要，并且后面所有的数据我都要
            if (i%2 != 0){
                flag = true;
            }

            if (flag){
                res.add(i);
            }
        }

        System.out.println(res);


    }
}
